<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><s:text name="content.list.title"/></title>
	<%@ include file="/common/meta.jsp"%>
	<%@ include file="/common/common.jsp"%>
	 <script type="text/javascript" src="${ctx}/js/My97DatePicker/WdatePicker.js"></script>
</head>
<body>
<div id="wrapper">
<div id="main_box">
	<div class="curmb"><s:text name="your.site.position"/>:<a href="${ctx}/main.action"><s:text name="homepage"/></a><span>></span><s:text name="content.title"/></div>
	<div class="listtit" id="listtit"><p><span><strong><s:text name="content.list.title"/>><s:property value="content.category.catName"/></strong></span></p></div>
	<s:hidden name="childId" id="childId"/>
	<s:form action="content-list" id="action_form">
	<div class="searchbox">
		<table class="searchTable">
			<tbody id="searchTable">
				<tr>
					<td class="text"><label for="search" class="labelKeywords">文章类型:</label></td>
				    <td class="input"><s:select list="contentTypes" name="content.docType" cssClass="selectClass"  listKey="key" listValue="value"  headerKey="" headerValue="---请选择---"/></td>
					<td class="text"><label for="search" class="labelKeywords">关键字:</label></td>
					<td class="input"><s:textfield name="content.keyword" cssClass="txtin150"/></td>
					<td class="text"><label for="search" class="labelKeywords">修改人:</label></td>
					<td class="input"><s:textfield name="content.updateLoginName" cssClass="txtin150"/></td>
		            <td rowspan="2"><input type="submit" value="查询" class="btnsearch" id="search_btn"/></td>
				</tr>
				<tr>
					<td class="text"><label for="qry_contentStatus">文章状态: </label></td>
					<td class="input"><s:select list="dicContentType" name="content.contentStatus" cssClass="selectClass" listKey="dictionaryKey" listValue="dictionaryValue" headerKey="" headerValue="---请选择---"/></td> 
					<td class="text"><label for="search" class="labelKeywords">起始时间:</label></td>
				    <td class="input"><input name="content.startTime"  class="Wdate" id="qry_startTime" readonly="true"  value="<s:property value="%{formatDate(content.startTime)}"/>"
							onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'qry_endTime\')||\'2030-10-01\'}',skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text"/></td>
					<td class="text"><label for="search" class="labelKeywords">终止时间:</label></td>
				    <td class="input"><input name="content.endTime"  class="Wdate" id="qry_endTime" readonly="true"  value="<s:property value="%{formatDate(content.endTime)}"/>"
							onFocus="WdatePicker({minDate:'#F{$dp.$D(\'qry_startTime\')}',skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text"/></td>
				</tr>
			</tbody>
		</table>
		<div class="clear"></div>
	</div>
	<div class="listoperate">
		<span class="cssa"  id="top_new_btn_f" >
		<s:if test="%{authLicence('3_3_3',content.category.categoryId)}">
		<input id="top_new_btn" type="button" value="<s:text name="new"/>" class="btnadd"/>
	<div class="listydzlayer" id="addType">
		<a href="#" id="normal_content">普通文章</a>
		<a href="#" id="software_content">软件文章</a>
		<a href="#" id="picture_content">图片文章</a>
		<a href="#" id="video_content">视频文章</a>
		<a href="#" id="flash_content">动画文章</a>
		<a href="#" id="link_content">链接文章</a>
	</div>
		</s:if>
		<s:else>
			<input type="button" value="<s:text name="new"/>" class="btnadd" disabled="disabled"/>
		</s:else>
		</span>
		<span>
			<input type="button" value="<s:text name="anti-selection"/>" class="btnlist2" id="top_anti_btn"/>
			<input type="button" value="<s:text name="delete"/>" class="btnlist2" id="top_del_btn"/>
			
			<input type="button" value="发布"  class="btnlist2" id="top_publish"/>
			
			<input type="button" value="展示状态修改"  class="btnlist4" id="top_showType_t"/>
			<input type="button" value="模板更换"  class="btnlist4" id="top_contentTpl_t"/>
			<input type="button" value="评论控制"  class="btnlist4" id="top_isComment_t"/>
			<input type="button" value="移动至"  class="btnlist4" id="listydzB"/>
		</span>
	</div>

	<div class="listbox" id="listbox">
		<table class="listgrid" id="listbox">
			<tbody>
				<tr id="table_th">
					<th><input type="checkbox" name="all" id="all_check"/></th>			
					<th>序号</th>
					<th>文章标题&nbsp;&nbsp;<a id="contentTitle_up" ><img src="${ctx}/imgs/up.png"/></a> <a style="display: none" id="contentTitle_down"><img src="${ctx}/imgs/down.png"/></a></th>	
					<th>类型</th>
					<th>创建人&nbsp;&nbsp;<a id="createLoginName_up"><img src="${ctx}/imgs/up.png"/></a> <a style="display: none" id="createLoginName_down"><img src="${ctx}/imgs/down.png"/></a></th>	
					<th>修改人&nbsp;&nbsp;<a id="updateLoginName_up"><img src="${ctx}/imgs/up.png"/></a> <a style="display: none" id="updateLoginName_down"><img src="${ctx}/imgs/down.png"/></a></th>
					<th>修改时间&nbsp;&nbsp;<a id="updateTime_up"><img src="${ctx}/imgs/up.png"/></a> <a style="display: none" id="updateTime_down"><img src="${ctx}/imgs/down.png"/></a></th>
					<th>发布人&nbsp;&nbsp;<a id="publishLoginName_up"><img src="${ctx}/imgs/up.png"/></a> <a style="display: none" id="publishLoginName_down"><img src="${ctx}/imgs/down.png"/></a></th>
					<th>文章状态&nbsp;&nbsp;<a id="contentStatus_up"><img src="${ctx}/imgs/up.png"/></a> <a style="display: none" id="contentStatus_down"><img src="${ctx}/imgs/down.png"/></a></th>		
					<th>点击量&nbsp;&nbsp;<a id="contentHits_up"><img src="${ctx}/imgs/up.png"/></a> <a style="display: none" id="contentHits_down"><img src="${ctx}/imgs/down.png"/></a></th>
					<th>是否置顶&nbsp;&nbsp;<a id="isTop_up"><img src="${ctx}/imgs/up.png"/></a> <a style="display: none" id="isTop_down"><img src="${ctx}/imgs/down.png"/></a></th>
					<th>操作</th>
				</tr>
				<s:set var="num" value="(page.pageNo-1)*page.pageSize"/> 
				<s:iterator value="page.result" status="s">  
					<tr>
					<td ><input type="checkbox" alt="<s:property value="contentStatus"/>" value="<s:property value="contentId"/>"  
				    		<s:if test='isLocked' >title="文章已锁定"  disabled="disabled"</s:if><s:else> name="key" </s:else>
				    ></td> 
					<td><s:property value="#s.count+#num"/></td>
					<td align="left"><s:property value="contentTitle"/><font color='red'><s:property value="Properties"/></font></td> 
			    	<td ><s:text name="content.contextType.%{contextType}"/></td> 	
			    	<td><s:property value="createLoginName"/></td>
			    	<td><s:property value="updateLoginName"/></td>
			    	<td><s:date name="updateTime"  format="yyyy-MM-dd HH:mm:ss"/></td>
			    	<td><s:property value="publishLoginName"/></td>
			    	<td><s:property value="%{getName(contentStatus,'CONTENT_STATUS')}"/></td>
			    	<td><s:property value="contentHits"/></td>
			    	<td> 
			    		<s:if test="isTop==1">是</s:if>
			    		<s:else>否</s:else>
			    	</td>
			    	<!-- 
					    	    	草稿： 		编辑	-1
					    	    	待审核：	审核	编辑	0	
					    	    	审核通过	发布	编辑	1
					    	    	审核不通过：	编辑	2
					    	    	已经发布	浏览	编辑	3					    	    	
					    	    	锁定（单独字段）：0  1  
					    	     -->
			    	
					<td>
						<s:if test="isLocked">
				    		<s:if test="%{authLicence('3_3_6',category.categoryId)}">
					    		<a href="###" onclick="unlock('<s:property value="contentId"/>')">解锁</a>
					    	</s:if>
					    	<s:else>文章已经被锁定
					    	</s:else>
				    	</s:if>
				    	<s:else>
			    			<s:if test="contentStatus.equals(\"0\")">
			    	 			<s:if test="%{authLicence('3_3_4',category.categoryId)}">	
									<a href="#this" onclick="goAudit('<s:property value="contentId"/>','1','<s:property value="contextType"/>')">审核</a><tt>|</tt>
								</s:if>
			    	 		</s:if> 
							<s:if test="contentStatus.equals(\"1\")">
									<s:if test="%{authLicence('3_3_2',category.categoryId)}">	
										<a href="#this" onclick="goPublish('<s:property value="contentId"/>','3')">发布</a><tt>|</tt>
									</s:if> 
						    </s:if>	 		     
					    	<s:if test="contentStatus.equals(\"3\")">
									<s:if test="(\"LinkContent\").equals(contextType)">
										<a href="#this" onclick="window.open('<s:property value="linkUrl"/>')">浏览</a><tt>|</tt>
									</s:if>
									<s:else>
										<a href="#this" onclick="window.open('<s:property value="content.category.site.siteDomain"/>/<s:property value="publishUrl"/>')">浏览</a><tt>|</tt>
									</s:else>
							</s:if> 
					    	<s:if test="%{authLicence('3_3_3',category.categoryId)}">								
								<s:if test="contextType.equals(\"Content\")"><a href="#this" onclick="goEdit('content.contentId','<s:property value="contentId"/>')"><s:text name="edit"/></a><tt>|</tt></s:if>
								<s:if test="contextType.equals(\"VideoContent\")"><a href="#this" onclick="goVideoEdit('videoContent.contentId','<s:property value="contentId"/>')"><s:text name="edit"/></a><tt>|</tt></s:if>
								<s:if test="contextType.equals(\"FlashContent\")"><a href="#this" onclick="goFlashEdit('flashContent.contentId','<s:property value="contentId"/>')"><s:text name="edit"/></a><tt>|</tt></s:if>
								<s:if test="contextType.equals(\"LinkContent\")"><a href="#this" onclick="goLinkEdit('linkContent.contentId','<s:property value="contentId"/>')"><s:text name="edit"/></a><tt>|</tt></s:if>
								<s:if test="contextType.equals(\"PictureContent\")"><a href="#this" onclick="goPicEdit('pictureContent.contentId','<s:property value="contentId"/>')"><s:text name="edit"/></a><tt>|</tt></s:if>
								<s:if test="contextType.equals(\"SoftwareContent\")"><a href="#this" onclick="goSoftEdit('softwareContent.contentId','<s:property value="contentId"/>')"><s:text name="edit"/></a><tt>|</tt></s:if>
							</s:if>
							<s:if test="%{authLicence('3_3_3',category.categoryId)}">
								<a href="#this" onclick="goDel('<s:property value="contentId"/>')"><s:text name="delete"/></a>
							</s:if> 
				    	</s:else> 
						</td>
					</tr>
				</s:iterator>
			</tbody>
		</table>
		
	</div>
	<div class="listoperateb h33">  
		<ul class="fl button_list">
			<li id="bottom_anti_btn" class="first"><s:text name="anti-selection"/></li>
			<li id="bottom_del_btn"><s:text name="delete"/></li>
			<li class="last more"><span>更多</span>
				<ul class="button_list2">
					<li id="bottom_publish">发布</li>
					<li id="bottom_showType_t">展示状态修改</li>
					<li id="bottom_contentTpl_t">模板更换</li>
					<li id="bottom_isComment_t">评论控制</li>
					<li id="bottom_listydzB">移动至</li>
				</ul>
			</li>
		</ul>
		<div class="pager fr w578"">
			<z:page numberNav="true" selectPageSize="true" input="true" id="ctrl" baseNav="false"/>
			<s:hidden name="content.orderBy" id="content_orderBy"/>
			<s:hidden name="content.orderFalg" id="content_orderFalg"/>
		</div>

	</div>
</div>
</s:form>

</div>

<div id='error' style="display: none"><s:actionmessage /></div>
</div>
<div id="lightbox_s" class="lightbox" >
	<div class="lighttit"><p><span><input type="button" value="&nbsp;" id="lightclose_s" class="lightclose" /><strong>展示状态修改</strong></span></p></div>
	<div class="lightmain">
		<div class="lightmaintit">展示状态修改
			<input type="checkbox" name="isTop_f" id="isTop_f"/><label for="isTop_f">置顶</label>
			<input type="checkbox" name="showType_o" id="showType_o_1"/><label for="showType_o_1">原创</label>
			<input type="checkbox" name="showType_o" id="showType_o_2"/><label for="showType_o_2">转载</label>
			<input type="checkbox" name="showType_o" id="showType_o_3"/><label for="showType_o_3">最新</label>
			<input type="checkbox" name="showType_o" id="showType_o_4"/><label for="showType_o_4">推荐</label>
			<input type="checkbox" name="showType_o" id="showType_o_5"/><label for="showType_o_5">精选</label>
			<input type="checkbox" name="showType_o" id="showType_o_6"/><label for="showType_o_6">热点</label>
		</div>
		<div class="ilghtmainbox" >
			<div id="authorSetDiv" >
				<table class="listgridb" cellspacing="1" id="listbox">
					<tbody>
						<tr>
							<td><select multiple="multiple" id="old_s" style="height: 300px;width: 200px"></select></td>
							<td>
								<input type="button" class="btnlist4" id="addall_s" value="===>"/><br/><br/>
								<input type="button" class="btnlist4" id="add_s" value="--->"/><br/><br/>
								<input type="button" class="btnlist4" id="del_s" value="<---"/><br/><br/>
								<input type="button" class="btnlist4" id="delall_s" value="<==="/>
							</td>
							<td><select multiple="multiple" id="new_s"  style="height: 300px;width: 200px"></td>
							</td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
		<div class="lightbtnbox"><input type="button" value="确认" id="lightsubmit_s" class="btnlist2"/></div>
	</div>
</div>
<div id="lightbox_t" class="lightbox" >
	<div class="lighttit"><p><span><input type="button" value="&nbsp;" id="lightclose_t" class="lightclose" /><strong>模板更换</strong></span></p></div>
	<div class="lightmain">
		<div class="lightmaintit">模板更换
			<s:select name="content.contentTpl" list="contenttpllist" /></select>
		</div>
		
		<div class="ilghtmainbox" >
			<div id="authorSetDiv" >
				<table  class="listgridb" cellspacing="1" id="listbox">
					<tbody>
						<tr>
							<td><select multiple="multiple" id="old_t" style="height: 300px;width: 200px"></select></td>
							<td>
								<input type="button" class="btnlist4" id="addall_t" value="===>"/><br/><br/>
								<input type="button" class="btnlist4" id="add_t" value="--->"/><br/><br/>
								<input type="button" class="btnlist4" id="del_t" value="<---"/><br/><br/>
								<input type="button" class="btnlist4" id="delall_t" value="<==="/>
							</td>
							<td><select multiple="multiple" id="new_t"  style="height: 300px;width: 200px"></td>
							</td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
		<div class="lightbtnbox"><input type="button" value="确认" id="lightsubmit_t" class="btnlist2"/></div>
	</div>
</div>
<div id="lightbox_c" class="lightbox" >
	<div class="lighttit"><p><span><input type="button" value="&nbsp;" id="lightclose_c" class="lightclose" /><strong>评论控制</strong></span></p></div>
	<div class="lightmain">
		<div class="lightmaintit">评论控制
			<s:if test="content.category.isComment">
			<input type="radio" name="isComment" value="true" id="yes" checked="checked"/><label for="yes">允许评论</label> 
			<input type="radio" name="isComment" value="false" id="no"/><label for="no">不允许评论</label> 
			</s:if>
			<s:else>
			<input type="radio" name="isComment" value="1" id="yes" disabled="disabled"/><label for="yes">允许评论</label> 
			<input type="radio" name="isComment" value="0" id="no" checked="checked" disabled="disabled"/><label for="no">不允许评论</label> 
			</s:else>
		</div>
		<div class="ilghtmainbox" >
			<div id="authorSetDiv" >
				<table  class="listgridb" cellspacing="1" id="listbox">
					<tbody>
						<tr>
							<td><select multiple="multiple" id="old_c" style="height: 300px;width: 200px"></select></td>
							<td>
								<input type="button" class="btnlist4" id="addall_c" value="===>"/><br/><br/>
								<input type="button" class="btnlist4" id="add_c" value="--->"/><br/><br/>
								<input type="button" class="btnlist4" id="del_c" value="<---"/><br/><br/>
								<input type="button" class="btnlist4" id="delall_c" value="<==="/>
							</td>
							<td><select multiple="multiple" id="new_c"  style="height: 300px;width: 200px"></td>
							</td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
		<div class="lightbtnbox"><input type="button" value="确认" id="lightsubmit_c" class="btnlist2"/></div>
	</div>
</div>
<div id="lightbox_b" class="lightbox" >
	<div class="lighttit"><p><span><input type="button" value="&nbsp;" id="lightclose_b" class="lightclose" /><strong>内容移动</strong></span></p></div>
	<div class="lightmain">
		<!-- <div class="lightmaintit">
		移动至：<select name="categoryList" id="categoryList"></select>
		请选择要移动的栏目:
		</div> -->
	 	<div class="ilghtmainbox">
			<div id="treeDiv_CatMove"  class='ztree' style="overflow-y:auto;overflow-x:auto;height:250px;"></div>
		</div> 
 
		<div class="lightbtnbox"><input type="button" value="确认" id="lightsubmit_b" class="btnlist2"/></div>
	</div>
</div>
<div id="lightbox_p" class="lightbox" >
	<div class="lighttit"><p><span><strong>发布文章</strong></span></p></div>
	<div class="lightmain">
		<div class="lightmaintit"><label id="returnInfo">正在发布文章....</label>
		</div>
		<div class="lightbtnbox">请稍等.....</div>
	</div>
</div>
</body>
</html>
<script type="text/javascript">
$$.layer("#top_new_btn_f","#addType","91");
$$.table_even(".listgrid");
</script>
<script type="text/javascript" defer="defer">

	//内容移动
	var disabled_ids = "";
	var srcid = "";
	var childid = "";
	$("#listydzB").click(function(){
		$.post("${ctx}/category/category-findchildid.action?category.categoryId=<s:property value="content.category.categoryId"/>",function(data){
			$("#childId").val(data);
		 	var childid = $("#childId").val();
		  	disabled_ids = '<s:property value="content.category.categoryId"/>'+"@"+childid;
		  	srcid = '<s:property value="content.category.categoryId"/>';
		  	$$.shade("#listydzB","#lightclose_b,#lightsubmit_b","#lightbox_b","321");
		  	var array_ = disabled_ids.split("@");
			loadZTree(array_,'treeDiv_CatMove');
		  	 
		}); 
		
	});
	$("#bottom_listydzB").click(function(){
			$.post("${ctx}/category/category-findchildid.action?category.categoryId=<s:property value="content.category.categoryId"/>",function(data){
				$("#childId").val(data);
			 	var childid = $("#childId").val();
			  	disabled_ids = '<s:property value="content.category.categoryId"/>'+"@"+childid;
			  	srcid = '<s:property value="content.category.categoryId"/>';
			  	$$.shade("#bottom_listydzB","#lightclose_b,#lightsubmit_b","#lightbox_b","321");
			  	var array_ = disabled_ids.split("@");
				loadZTree(array_,'treeDiv_CatMove');			  	
			}); 
			
		});
	
	$("#lightsubmit_b").click(function(){
		var ids = inputvalue();  
		var treeObj = $.fn.zTree.getZTreeObj('treeDiv_CatMove');
		nodes = treeObj.getCheckedNodes(true);
		if(nodes){
			var targetId = nodes[0].id; 
			if(!targetId){
				alert('请选择移动的目标栏目');
				return;
			}
		//把文章的父id改为目标id
			if(confirm("确实要移动文章吗？")){
				$.post(
						"${ctx}/content/content-move.action?time="+new Date().getTime()+"&content.category.categoryId="+targetId+"&contentIds="+ids,
					function(data){
					if(data == "yes"){
						alert("移动成功");
						window.location.reload(); 
					}else{
						alert("移动失败 ");
						window.location.reload(); 
					}
				});} 
		}
		
		
	});
	////文章id拼接 
	function inputvalue(){
		var d = $("#listbox input"), i = 0, j = d.length, str = "";
	   for ( ; i < j ; i ++ ) {
				str += (d[i].type == "checkbox" && d[i].id != "totalCheck" && d[i].checked == true ) ? d[i].value + "," : "";
		};	
		return (str.slice(0,-1)); 
	};
	
	///////
	$("#lightclose_b").click(function(){
		$("#old_b li").remove();
		$("#new_b li").remove();
	});
	$("#addall_b").click(function(){
		$("#new_b").append($("#old_b li"));
		$("#old_b li").remove();
	});
	$("#delall_b").click(function(){
		$("#old_b").append($("#new_b li"));
		$("#new_b li").remove();
	});

	$("#add_b").click(function(){
		var m=$("#old_b li.current").length;
		var n=$("#new_b li").length;
		$("#new_b").append($("#old_b li.current"));
		$("#old_b li.current").remove();
		for(var i=n;i<m+n;i++){
			$("#new_b li").eq(i).removeClass("current");
		}
	//	$("#new_b").append($("#old_b option:checked"));
	//	$("#old_b option:checked").remove();
	});
	$("#del_b").click(function(){
		var m=$("#new_b li.current").length;
		var n=$("#old_b li").length;
		$("#old_b").append($("#new_b li.current"));
		$("#new_b li.current").remove();
		for(var i=n;i<m+n;i++){
			$("#old_b li").eq(i).removeClass("current");
		}
	});

	//修改展示状态
	$("#showType_o_1").click(function(){
		if($(this).attr("checked")==""){
			$("#showType_o_2").attr("checked","checked");
		}else{
			$("#showType_o_2").attr("checked","");
		}
	});
	$("#showType_o_2").click(function(){
		if($(this).attr("checked")==""){
			$("#showType_o_1").attr("checked","checked");
		}else{
			$("#showType_o_1").attr("checked","");
		}
	});
	$("#top_showType_t").click(function(){
		$$.shade("#top_showType_t","#lightclose_s,#lightsubmit_s","#lightbox_s","600");
		var str="";
		$("input[name=key]:checked").each(function(){
			str+="<option value="+$(this).attr("value")+">"+$(this).attr("id")+"</option>";
		});
		$("#old_s").append(str);
	});
	$("#bottom_showType_t").click(function(){
		$$.shade("#bottom_showType_t","#lightclose_s,#lightsubmit_s","#lightbox_s","600");
		var str="";
		$("input[name=key]:checked").each(function(){
			str+="<option value="+$(this).attr("value")+">"+$(this).attr("id")+"</option>";
		});
		$("#old_s").append(str);
	});
	$("#lightclose_s").click(function(){
		$("#old_s option").remove();
		$("#new_s option").remove();
		$("input[name=isTop_f]").attr("checked","");
		$("input[name=showType_o]").each(function(){
			$(this).attr("checked","");
		});
	});
	$("#addall_s").click(function(){
		$("#new_s").append($("#old_s").html());
		$("#old_s option").remove();
	});
	$("#delall_s").click(function(){
		$("#old_s").append($("#new_s").html());
		$("#new_s option").remove();
	});
	$("#add_s").click(function(){
		$("#new_s").append($("#old_s option:selected"));
		$("#old_s option:selected").remove();
	});
	$("#del_s").click(function(){
		$("#old_s").append($("#new_s option:selected"));
		$("#new_s option:selected").remove();
	});
	$("#lightsubmit_s").click(function(){
		var contentId = "";
		var isTop;
		var showType = "";
		if($("input[name=isTop_f]").attr("checked")==""){
			isTop = false;
		}else{
			isTop = true;
		}
		$("input[name=showType_o]").each(function(){
			if($(this).attr("checked")==""){
				showType+="0";
			}else{
				showType+="1";
			}
		});
		showType+="0";
		var obj="";
		obj+=showType.substring(0, 1);
		obj+=showType.substring(2, showType.length);
		showType = obj;
		$("#new_s option").each(function(){
			contentId += $(this).val()+",";
		});
		if(contentId!=""){
			$.ajax({	
				url:"${ctx}/content/content-batch.action?time="+new Date().getTime(),
				data:{"content.contentId":contentId,
					  "content.isTop":isTop,
					  "content.showType":showType},
				dataType:"text",
				type:"post",
				success:function(data){
					if(data=="sure"){
						alert("更改成功！");
						location.reload();
					}else{
						alert("更改失败！"); 
					}
				}
			});
		} 
		$("#old_s option").remove();
		$("#new_s option").remove();
		$("input[name=isTop_f]").attr("checked","");
		$("input[name=showType_o]").each(function(){
			$(this).attr("checked","");
		});
	});
	//模板更换
	$("#top_contentTpl_t").click(function(){
		$$.shade("#top_contentTpl_t","#lightclose_t,#lightsubmit_t","#lightbox_t","600");
		var str="";
		$("input[name=key]:checked").each(function(){
			str+="<option value="+$(this).attr("value")+">"+$(this).attr("id")+"</option>";
		});
		$("#old_t").append(str);
	});
	$("#bottom_contentTpl_t").click(function(){
		$$.shade("#bottom_contentTpl_t","#lightclose_t,#lightsubmit_t","#lightbox_t","600");
		var str="";
		$("input[name=key]:checked").each(function(){
			str+="<option value="+$(this).attr("value")+">"+$(this).attr("id")+"</option>";
		});
		$("#old_t").append(str);
	});
	$("#lightclose_t").click(function(){
		$("#old_t option").remove();
		$("#new_t option").remove();
	});
	$("#addall_t").click(function(){
		$("#new_t").append($("#old_t").html());
		$("#old_t option").remove();
	});
	$("#delall_t").click(function(){
		$("#old_t").append($("#new_t").html());
		$("#new_t option").remove();
	});
	$("#add_t").click(function(){
		$("#new_t").append($("#old_t option:selected"));
		$("#old_t option:selected").remove();
	});
	$("#del_t").click(function(){
		$("#old_t").append($("#new_t option:selected"));
		$("#new_t option:selected").remove();
	});
	$("#lightsubmit_t").click(function(){
		var contentId = "";
		var tplId = $("select[name=contentTpl] option:selected").val();
		$("#new_t option").each(function(){
			contentId += $(this).val()+",";
		});
		if(contentId!=""){
			$.ajax({	
				url:"${ctx}/content/content-batch.action?time="+new Date().getTime(),
				data:{"content.contentId":contentId,
					  "content.contentTpl":tplId},
				dataType:"text",
				type:"post",
				success:function(data){
					if(data=="sure"){
						alert("更改成功！"); 
						location.reload();
					}else{
						alert("更改失败！"); 
					}
				}
			});
		}
		$("#old_t option").remove();
		$("#new_t option").remove();
	});
	//评论控制
	$("#top_isComment_t").click(function(){
		$$.shade("#top_isComment_t","#lightclose_c,#lightsubmit_c","#lightbox_c","600");
		var str="";
		$("input[name=key]:checked").each(function(){
			str+="<option value="+$(this).attr("value")+">"+$(this).attr("id")+"</option>";
		});
		$("#old_c").append(str);
	});
	$("#bottom_isComment_t").click(function(){
		$$.shade("#bottom_isComment_t","#lightclose_c,#lightsubmit_c","#lightbox_c","600");
		var str="";
		$("input[name=key]:checked").each(function(){
			str+="<option value="+$(this).attr("value")+">"+$(this).attr("id")+"</option>";
		});
		$("#old_c").append(str);
	});
	$("#lightclose_c").click(function(){
		$("#old_c option").remove();
		$("#new_c option").remove();
	});
	$("#addall_c").click(function(){
		$("#new_c").append($("#old_c").html());
		$("#old_c option").remove();
	});
	$("#delall_c").click(function(){
		$("#old_c").append($("#new_c").html());
		$("#new_c option").remove();
	});
	$("#add_c").click(function(){
		$("#new_c").append($("#old_c option:selected"));
		$("#old_c option:selected").remove();
	});
	$("#del_c").click(function(){
		$("#old_c").append($("#new_c option:selected"));
		$("#new_c option:selected").remove();
	});
	$("#lightsubmit_c").click(function(){
		var contentId = "";
		var isComment = $("input[name=isComment]:checked").val();
		$("#new_c option").each(function(){
			contentId += $(this).val()+",";
		});
		if(contentId!=""){
			$.ajax({	
				url:"${ctx}/content/content-batch.action?time="+new Date().getTime(),
				data:{"content.contentId":contentId,
					  "content.isComment":isComment},
				dataType:"text",
				type:"post",
				success:function(data){
					if(data=="sure"){
						alert("更改成功！"); 
						location.reload();
					}else{
						alert("更改失败！"); 
					}
				}
			});
		}
		$("#old_c option").remove();
		$("#new_c option").remove();
	});
	
	
	actionName = "content";	
	confirmStr = "<s:text name="delete.confirm"/>";
	chiocenothing = "<s:text name="chiocenothing"/>";
	$(function(){
		$("#top_new_btn").click(goNormalContentNew);
 		$("#normal_content").click(goNormalContentNew);
 		$("#picture_content").click(goPictureContentNew);
 		$("#video_content").click(goVideoContentNew);
 		$("#flash_content").click(goFlashContentNew);
 		$("#link_content").click(goLinkContentNew);
 		$("#software_content").click(goSoftwareContentNew);
 		$("#top_anti_btn").click(antiSelect);
 		$("#top_del_btn").click(goBatchDel);
 		$("#bottom_del_btn").click(goBatchDel);
 		$("#bottom_anti_btn").click(antiSelect);
		$("#search_btn").click(search);
		$("#all_check").click(selAll);
		$("#top_publish").click(publish);
		$("#bottom_publish").click(publish);
		tableThSort();
	});
	
	function publish(){
		if($("input[name='key']:checked").size()==0){
			alert(chiocenothing);
			return;
		}
		var id ='';
		var flag = false;
		<s:if test="!content.category.isAudit">
		$("input[name='key']:checked").each(function(){
			if($(this).attr("alt")!=1&&$(this).attr("alt")!=3&&$(this).attr("alt")!=0){
				flag=true;
			}
			id+=$(this).val()+",";
		});
		</s:if>
		<s:else>
		$("input[name='key']:checked").each(function(){
			if($(this).attr("alt")!=1&&$(this).attr("alt")!=3){
				flag=true;
			}
			id+=$(this).val()+",";
		});
		</s:else>
		
		if(flag){
			alert("文章无法发布！请选择可发布的文章");
			return false;
		}
		$$.shade("#bottom_publish","#lightclose_p,#lightsubmit_p","#lightbox_p","300");
		document.location.href = "${ctx}/generate/publish-content.action?orig=input&contextType=0&content.category.categoryId=<s:property value="content.category.categoryId"/>&targets="+id+"&cflag=3&type=content";
	}
	
	function search(){
		$("#ctrl_page_input").val(1);
		$("#action_form").attr("action","${ctx}/content/content-list.action?content.category.categoryId=<s:property value="content.category.categoryId"/>");
		$("#action_form").submit();
	}
	
	function goPublish(id,flag){
		$$.shade("#bottom_publish","#lightclose_p,#lightsubmit_p","#lightbox_p","300");
		document.location.href="${ctx}/generate/publish-content.action?orig=input&contextType=0&content.category.categoryId=<s:property value="content.category.categoryId"/>&targets="+id+"&cflag="+flag+"&type=content";
	}
	
	function goNormalContentNew(){
		document.location.href="content-input.action?orig=input&contextType=0&content.category.categoryId=<s:property value="content.category.categoryId"/>";
	}
	function goPictureContentNew(){
		document.location.href="picturecontent-input.action?orig=input&contextType=0&pictureContent.category.categoryId=<s:property value="content.category.categoryId"/>";
	}
	function goVideoContentNew(){
		document.location.href="videocontent-input.action?orig=input&contextType=0&videoContent.category.categoryId=<s:property value="content.category.categoryId"/>";
	}
	function goFlashContentNew(){
		document.location.href="flashcontent-input.action?orig=input&contextType=0&flashContent.category.categoryId=<s:property value="content.category.categoryId"/>";
	}
	function goLinkContentNew(){
		document.location.href="linkcontent-input.action?orig=input&contextType=0&linkContent.category.categoryId=<s:property value="content.category.categoryId"/>";
	}
	function goSoftwareContentNew(){
		document.location.href="softwarecontent-input.action?orig=input&contextType=0&softwareContent.category.categoryId=<s:property value="content.category.categoryId"/>";
	}
	function goAudit(id,flag,type){
		type2= type.toLowerCase();
		var str = type.substring(0,1);
		var type3 = str.toLowerCase()+type.substring(1,type.length);
		document.location.href=type2+"-input.action?orig=input&contextType=0&"+type3+".category.categoryId=<s:property value="content.category.categoryId"/>&"+type3+".contentId="+id+"&cflag="+flag;
	}
	function unlock(id){
		document.location.href="content-unlock.action?orig=input&contextType=0&content.category.categoryId=<s:property value="content.category.categoryId"/>&content.contentId="+id;
	}
	function goSoftEdit(param,id){
		document.location.href="softwarecontent-input.action?"+param+"="+id+"&orig=edit";
	}
	function goVideoEdit(param,id){
		document.location.href="videocontent-input.action?"+param+"="+id+"&orig=edit";
	}
	function goPicEdit(param,id){
		document.location.href="picturecontent-input.action?"+param+"="+id+"&orig=edit";
	}
	function goFlashEdit(param,id){
		document.location.href="flashcontent-input.action?"+param+"="+id+"&orig=edit";
	}
	function goLinkEdit(param,id){
		document.location.href="linkcontent-input.action?"+param+"="+id+"&orig=edit";
	}
	$(document).ready(function() {
		var tpls = "<s:property value="content.category.catContentTplSet"/>";
		var tpl = tpls.split(",");
		var str = "";
		for(var i = 0;i<tpl.length;i++){
			str+="<option value="+tpl[i]+">"+tpl[i]+"</option>";
		}
		$("select[name=contentTpl]").append(str);
		<s:if test="hasActionMessages()">
		var info = $('.actionMessage li span').text();
		alert(info);
		</s:if>
	});
	//进入子栏目管理页面
	function goNnter2(){
		var categoryId=location.href;
		var num=categoryId.indexOf("=");
		categoryId=categoryId.substr(num+1); 
		
		var id = "<s:property value='content.category.categoryId'/>";
		if (window.navigator.userAgent.indexOf("Chrome")>=0){
			window.parent.frames["leftframe"].contentWindow.expandTarget("ztree_content",id);
		}
		else{
			window.parent.frames["leftframe"].expandTarget("ztree_content",id);
		}
	}
	function goNnter(categoryId){
		$("${ctx}/category/category-list.action?category.categoryId="+categoryId,function(data){
			if(data.length>0){
				document.location.href="${ctx}/category/category-list.action?category.categoryId="+categoryId;
			}else{
				alert("该栏目没有子栏目");
			}
		});
	}
	function synchronous(categoryId){
		if (categoryId){
			var now_onclick=$(window.parent.frames["leftframe"].frames["leftmenutree2"].document).find(".dojoTreeNodeLabelSelected").parent("span").parent(".dojoTreeNode");
			var now_child=now_onclick.children("div").children(".dojoTreeNode");
			var temp;
			for(var i=0;i<now_child.length;i++){
				temp=now_child.eq(i).children("span").children("span").children("a").attr("href").replace("category-list.action?category.categoryId=","");
				if (temp==categoryId){break;}
			}
			if (now_child.eq(i).children("div").css("display")=="none"){
				now_child.eq(i).children("img").eq(now_child.eq(i).children("img").length-1).click();
			}
		}
		else {
			
		}
	}
	$(function(){
		goNnter2();
	});
	</script>
<link href="${ctx}/css/zTreeStyle/zTreeStyle.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="${ctx}/js/jquery.ztree.core-3.0.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery.ztree.excheck-3.0.js"></script>
<script type="text/javascript">
  function loadCatetree (type,needUrl,id){	
	$.ajax({
		async:false, 
		url:"${ctx}/site/sitetree.action?t="+new Date().getTime(),
		data:{"type":type,"needurl":needUrl},
		type:"post",
		dataType:"text",
		success:function(ss){
			var setting = {
					check: {
						enable: true,
						chkStyle: "radio",
						radioType: "all"
					},
					data: {
						simpleData: {
							enable: true
						}
					}
				};

			var zNodes = eval('('+ss+')');
			$.fn.zTree.init($("#"+id), setting, zNodes);
			 
		}
	});
} 	
  /**加载ztree  初始化 :arr :disableids*/
  function loadZTree(arr ,ztreeId){  
  	loadCatetree(false,false,ztreeId);    
      var treeObj = $.fn.zTree.getZTreeObj(ztreeId);
      for(var i=0;i<arr.length;i++){
      	var node = treeObj.getNodeByParam("id",arr[i], null);
      	if(node){
      		node.nocheck = true; 
      		treeObj.updateNode(node);
      	}
      }
  }  
  $(function(){
	  var now_obj=null;
	  $(".button_list li.more").click(function(event){
		  now_obj=$(this);
		  if (now_obj.children('.button_list2').css('display')=='block'){
			  now_obj.children('.button_list2').hide();
		  }else{
			  if (($('body').height()-now_obj.position().top-23)>now_obj.children('.button_list2').height()){
				  now_obj.children('.button_list2').css({top:23,left:-1}).show();
			  }else {
				  now_obj.children('.button_list2').css({top:(-now_obj.children('.button_list2').height()-2),left:-1}).show();
			  }  
		  }

		  event.stopPropagation();
	  });
	  $('body').click(function(){
		  if (now_obj!=null && now_obj.children('.button_list2').css('display')=='block'){
			  now_obj.children('.button_list2').hide();
		  }
	  });
	  if ($.browser.msie) {
		  $('#main_box').width($('#main_box').width()-25);
		}
  })
  
  function  tableThSort(){
	$("#table_th").find('a').each(function(i,item){
		$(item).bind({
			click:function(){
				tableThSubmit(item);
			}
		});
	}); 
}

function tableThSubmit(item){
	var obj = $(item).attr('id');
	var arr = obj.split('_');
	$("#content_orderBy").val(arr[0]);
	$("#content_orderFalg").val(arr[1]);
	$("#action_form").attr("action","${ctx}/content/content-list.action?content.category.categoryId=<s:property value="content.category.categoryId"/>");
	$("#action_form").submit();
}

//排序图标显示
$(function(){
	var aa = $("#content_orderBy").val();
	var bb = $("#content_orderFalg").val();
	if(bb == "up"){
		$("#"+aa+"_up").hide();
		$("#"+aa+"_down").show();
	}else{
		$("#"+aa+"_down").hide();
		$("#"+aa+"_up").show();
	}
})

</script>